<!--
// +----------------------------------------------------------------------
// | Created by PHPstorm: JRKAdmin框架 [ JRKAdmin ]
// +----------------------------------------------------------------------
// | Copyright (c) 2019~2022 [LuckyHHY] All rights reserved.
// +----------------------------------------------------------------------
// | SiteUrl: http://www.luckyhhy.cn
// +----------------------------------------------------------------------
// | Author: LuckyHhy <jackhhy520@qq.com>
// +----------------------------------------------------------------------
// | Date: 2020/3/6-11:21
// +----------------------------------------------------------------------
// | Description:
// +----------------------------------------------------------------------
*-->

{extend name='public/base' /}


{block name="content"}

<div class="layui-col-md12">

    <div class="layui-card">

        <div class="layui-card-body">

            <div class="layui-tab layui-tab-brief" lay-filter="demo">
                <ul class="layui-tab-title">
                    <li class="layui-this">七牛云配置</li>
                    <li>阿里云OSS</li>
                </ul>
                <div class="layui-tab-content" >

                    <!--七牛云配置-->
                    <div class="layui-tab-item layui-show">

                        <div class="layui-form"  lay-filter="">

                            <blockquote class="layui-elem-quote">
                                <p class="margin-bottom-5 font-w7">文件将上传到七牛云存储，对象存储需要配置为公开访问的Bucket空间！</p>
                                完成实名认证后可获得10G免费存储空间哦！<a target="_blank" href="https://portal.qiniu.com/signup?code=3lhz6nmnwbple">我要免费申请</a>
                            </blockquote>

                            <div class="layui-form-item" >
                                <label class="layui-form-label label-required-next">访问协议</label>
                                <div class="layui-input-block">
                                    {foreach ['http','https','auto'] as $pro}
                                    {if GetSysConfig('qiniu_is_https') eq $pro}
                                    <input  type="radio" name="qiniu_is_https" value="{$pro}" checked> {$pro}
                                    {else}
                                    <input type="radio" name="qiniu_is_https" value="{$pro}" > {$pro}
                                    {/if}
                                    {/foreach}
                                    <p class="help-block">七牛云存储空间所在区域，需要严格对应储存所在区域才能上传文件。</p>
                                </div>

                            </div>
                            <div class="layui-form-item" >
                                <label class="layui-form-label label-required-next">存储区域</label>
                                <div class="layui-input-block">
                                    {foreach ['华东','华北','华南','北美'] as $area}

                                    {if GetSysConfig('qiniu_region') eq $area}
                                    <input checked type="radio" name="qiniu_region" value="{$area}" >
                                    {else}
                                    <input type="radio" name="qiniu_region" value="{$area}" >
                                    {/if}
                                    {$area}
                                    {/foreach}

                                </div>

                            </div>

                            <div class="layui-form-item" >
                                <label class="layui-form-label label-required-next">空间名称</label>
                                <div class="layui-input-block">
                                    <input type="text" name="qiniu_bucket" lay-vertype="tips" lay-verify=required" value="{:GetSysConfig('qiniu_bucket')}" placeholder="请输入七牛云存储 Bucket (空间名称)" class="layui-input">
                                    <p class="help-block">填写七牛云存储空间名称，如：static</p>
                                </div>

                            </div>

                            <div class="layui-form-item" >
                                <label class="layui-form-label label-required-next">访问域名</label>
                                <div class="layui-input-block">
                                    <input type="text" name="qiniu_domain" lay-vertype="tips" lay-verify=required" value="{:GetSysConfig('qiniu_domain')}" placeholder="请输入七牛云存储 Domain (访问域名)" class="layui-input">
                                    <p class="help-block">填写七牛云存储访问域名，如：static.ctolog.cc</p>
                                </div>

                            </div>

                            <div class="layui-form-item" >
                                <label class="layui-form-label label-required-next">访问密钥</label>
                                <div class="layui-input-block">
                                    <input type="text" name="qiniu_access_key" lay-vertype="tips" lay-verify=required" value="{:GetSysConfig('qiniu_access_key')}" placeholder="请输入七牛云 AccessKey (访问密钥)" class="layui-input">
                                    <p class="help-block">可以在 [ 七牛云 > 个人中心 ] 设置并获取到访问密钥。</p>
                                </div>

                            </div>

                            <div class="layui-form-item" >
                                <label class="layui-form-label label-required-next">安全密钥</label>
                                <div class="layui-input-block">
                                    <input type="text" name="qiniu_secret_key" lay-vertype="tips" lay-verify=required" value="{:GetSysConfig('qiniu_secret_key')}" maxlength="43" placeholder="请输入七牛云 SecretKey (安全密钥)" class="layui-input">
                                    <p class="help-block">可以在 [ 七牛云 > 个人中心 ] 设置并获取到安全密钥。</p>
                                </div>
                            </div>


                            <div class="layui-form-item">
                                <div class="layui-input-block">
                                    <button class="layui-btn" lay-submit  lay-filter="set_qiniu_setting">确认保存</button>
                                </div>
                            </div>


                        </div>
                    </div>


                    <!--oss配置-->
                    <div class="layui-tab-item">

                        <div class="layui-form"  lay-filter="">

                            <blockquote class="layui-elem-quote">
                                <p class="margin-bottom-5 font-w7">文件将上传到阿里云OSS空间，需要配置OSS公开访问及跨域策略！</p>
                                目前已实现自动创建空间及配置访问策略！<a target="_blank" href="https://promotion.aliyun.com/ntms/yunparter/invite.html?userCode=08p1pddw">我要免费申请</a>
                            </blockquote>


                            <div class="layui-form-item">
                                <label class="layui-form-label ">Protocol<br><span class="nowrap color-desc">访问协议</span></label>
                                <div class="layui-input-block">
                                    {foreach ['http','https','auto'] as $pro}
                                    {if GetSysConfig('storage_oss_is_https') eq $pro}
                                    <input checked type="radio" name="storage_oss_is_https" value="{$pro}" > {$pro}
                                    {else}
                                    <input type="radio" name="storage_oss_is_https" value="{$pro}"> {$pro}
                                    {/if}
                                    {/foreach}
                                    <p class="help-block">阿里云对象存储访问协议（http、https、auto），其中 https 需要配置证书才能使用，auto 为相对协议自动根据域名切换http与https。</p>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">Bucket<br><span class="nowrap color-desc">空间名称</span></label>
                                <div class="layui-input-block">
                                    <input type="text" name="storage_oss_bucket" lay-vertype="tips" lay-verify=required" value="{:GetSysConfig('storage_oss_bucket')}" placeholder="请输入OSS Bucket (空间名称)" class="layui-input">
                                    <p class="help-block">填写OSS存储空间名称，如：think-admin-oss（需要是全区唯一的值，不存在时会自动创建）</p>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">EndPoint<br><span class="nowrap color-desc">数据中心</span></label>
                                <div class="layui-input-block">
                                    <select  name="storage_oss_endpoint" lay-vertype="tips" lay-verify=required" class="layui-select" lay-search>
                                        {foreach $ossPoints as $k=>$p}
                                        {if GetSysConfig('storage_oss_endpoint') eq $k}
                                        <option selected value="{$k}">{$p} <span class="font-s10 color-desc">({$k})</span></option>
                                        {else}
                                        <option value="{$k}">{$p} <span class="font-s10 color-desc">({$k})</span></option>
                                        {/if}
                                        {/foreach}
                                    </select>
                                    <p class="help-block">请选择OSS数据中心访问节点，有效值如：oss-cn-shenzhen.aliyuncs.com</p>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">AccessKey<br><span class="nowrap color-desc">访问密钥</span></label>
                                <div class="layui-input-block">
                                    <input type="text" name="storage_oss_keyid" lay-vertype="tips" lay-verify=required" value="{:GetSysConfig('storage_oss_keyid')}" maxlength="16" placeholder="请输入OSS AccessKey (访问密钥)" class="layui-input">
                                    <p class="help-block">可以在 [ 阿里云 > 个人中心 ] 设置并获取到访问密钥。</p>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">SecretKey<br><span class="nowrap color-desc">安全密钥</span></label>
                                <div class="layui-input-block">
                                    <input type="text" name="storage_oss_secret" lay-vertype="tips" lay-verify=required" value="{:GetSysConfig('storage_oss_secret')}" maxlength="30" placeholder="请输入OSS SecretKey (安全密钥)" class="layui-input">
                                    <p class="help-block">可以在 [ 阿里云 > 个人中心 ] 设置并获取到安全密钥。</p>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">Domain<br><span class="nowrap color-desc">访问域名</span></label>
                                <div class="layui-input-block">
                                    <input type="text" name="storage_oss_domain" value="{:GetSysConfig('storage_oss_domain')}" placeholder="请输入OSS存储 Domain (访问域名)" class="layui-input">
                                    <p class="help-block">填写OSS存储外部访问域名，如：think-admin-oss.oss-cn-shenzhen.aliyuncs.com（正常情况下是自动获取的）</p>
                                </div>
                            </div>


                            <div class="layui-form-item">
                                <div class="layui-input-block">
                                    <button class="layui-btn" lay-submit  lay-filter="set_oss_setting">确认保存</button>
                                </div>
                            </div>


                        </div>
                    </div>




                </div>
            </div>



        </div>
    </div>

</div>


{/block}

{block name="js"} <!--js处理区-->

<script>

    layui.use(['element','form', 'jquery','lucky'], function () {
        var element = layui.element;
        var form = layui.form;
        var $ = layui.jquery;
        var lucky=layui.lucky;

        form.render();



        /**
         * 七牛云配置
         */
        form.on('submit(set_qiniu_setting)', function (data) {
            lucky.FormSubmit("{:url('setting/sitePost')}",data.field,0,0,1);
            return false;
        });



        /**
         * oss配置
         */
        form.on('submit(set_oss_setting)', function (data) {
            lucky.FormSubmit("{:url('setting/sitePost')}",data.field,0,0,1);
            return false;
        });




    });

</script >


{/block}
